<template>
  <el-drawer
      title="文章详情"
      :visible.sync="dialogVisible"
      :size="700"
    >
    <div class="box-card">
      <el-form ref="elForm" :model="articleInfo" label-width="80px">
          <el-form-item label="文章标题" prop="title">
            <span>{{ articleInfo.title }}</span>
          </el-form-item>

          <el-form-item label="文章封面" title="picUrl">
            <img :src="articleInfo.picUrl | getImgUrl" class="avatar">
          </el-form-item>

          <el-form-item label="文章内容" prop="detail">
            <div v-html="articleInfo.detail" class="detail"></div>
          </el-form-item>
        </el-form>
    </div>
    <div class="footer">
      <el-button @click="save(2)">驳回</el-button>
      <el-button type="primary" @click="save(1)">通过</el-button>
    </div>
  </el-drawer>
</template>
<script>
import { auditArticle } from '@/api/articles'
export default {
  name: 'ArticleDetail',
  components: {},
  data () {
    return {
      dialogVisible: false,
      articleInfo: {
        title: '', // 文章标题
        picUrl: '', // 文章封面
        detail: '', // 文章内容
        wzType: '', // 文章类型
        id: '',
        status: '' // 文章审核状态
      }
    }
  },
  // 计算属性
  computed: {},
  watch: {},
  mounted () {},
  methods: {
    isShow (data) {
      this.dialogVisible = true
      const formData = this.articleInfo
      for (const key in formData) {
        formData[key] = data[key]
      }
    },
    close () {
      this.$refs.elForm.resetFields()
      this.dialogVisible = false
    },
    async save (status) {
      const params = {
        ...this.articleInfo,
        status
      }
      await auditArticle(params)
      this.$notify.success({
        title: '审核完成'
      })
      this.$emit('update:visible')
      this.close()
    }
  }
}
</script>
<style lang="scss" scoped>
  .box-card {
    margin-bottom: 10px;
    padding-right: 20px;
    width: 100%;
    padding-right: 20px;
  }
  .avatar {
    width: 145px;
    height: 145px;
    display: block;
  }
  .detail {
    width: 100%;
    height: 450px;
    overflow-y: auto;
    border: 1px solid #ccc;
    ::v-deep .lake-content {
      padding: 20px;
    }
    ::v-deep img {
      width: 100%;
    }
  }
.footer {
  display: flex;
  justify-content: space-around;
  margin-bottom: 40px;
  padding-left: 80px;
  padding-right: 20px;
  .el-button {
    width: 100%;
  }
}
</style>
